"""
购买相关
"""
from common.models import db
from datetime import datetime
from common.models.user import UserBase
from common.models.course import Base, Course


class Goods(Base):
    """
    商品表
    """
    __tablename__ = 'tb_goods'

    product_id = db.Column(db.Integer, primary_key=True, doc='商品id')
    course = db.Column(db.Integer, db.ForeignKey("tb_course.id", ondelete="CASCADE"))
    goods_type = db.Column(db.String(24), doc='商品种类', default='course')
    title = db.Column(db.String(24), doc='商品名称')
    price = db.Column(db.DECIMAL(20, 5), doc='商品价格')
    channel_type = db.Column(db.String(24), doc='购买渠道', default='支付宝')
    period = db.Column(db.Integer, default=365, doc='有效期')
    is_launched = db.Column(db.Boolean, default=True)

    def __str__(self):
        return self.title


# class Orders(Base):
#     __tablename__ = 'tb_order'
#     PAY_METHOD = (
#         (1, "支付宝"),
#     )
#     ORDER_STATUS = (
#         (1, "待支付"),
#         (2, "已支付"),
#         (3, "已取消"),
#     )
#     user = models.ForeignKey('user.User', on_delete=models.PROTECT, verbose_name="下单用户")
#     goods = models.ForeignKey(Goods, on_delete=models.PROTECT)
#     order_id = models.CharField('订单号', max_length=24)
#     trade_no = models.CharField('支付宝订单号', max_length=32, null=True)  # 28位
#     pay_time = models.DateTimeField('支付时间', null=True)
#     pay_method = models.CharField('支付方式', choices=PAY_METHOD, default=1, max_length=8)
#     status = models.CharField('支付状态', choices=ORDER_STATUS, default=1, max_length=8)
#     total_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="商品总金额")

#
#     class Meta:
#         db_table = 'tb_orders'
#
#     def __str__(self):
#         return self.order_id
